package com.mc.lp.view.validator;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

import com.mc.lp.shared.vo.StudentRecordVO;
/*
 * @author aphanda
 * @date Sep 19, 2014
 * @time 3:22:05 PM
 */

public class AcademicValidator implements Validator{

	public boolean supports(Class<?> clazz) {
		return StudentRecordVO.class.equals(clazz);
		
	}

	public void validate(Object target, Errors errors) {
		//AN
		//AP validators are looking very good, can we think more and these validators to our handler framework this will be very good to have architecture.
		//we need to think how we can leverage its functionality.
		
//		AcademicRecordVO vo = (AcademicRecordVO)target;
//		
//		 if(vo.getGradeId() == null) {
//	            errors.rejectValue("grade", "grade[emptyMessage]");
//	        }
//	        else if(vo.getGrade().length() < 1 || vo.getGradeId().length() > 20){
//	            errors.rejectValue("grade", "grade[invalidLength]");
//	        }
//
//	        if(vo.getMarks() == null) {
//	            errors.rejectValue("marks", "marks[emptyMessage]");
//	        }
//	        else if(vo.getMarks() < 1 || vo.getMarks()> 110){
//	            errors.rejectValue("marks", "marks[invalidAge]");
//	        }
	}
}
